package com.hj.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.hj.service.SingleResetService;
import com.hj.service.SingleStopService;
import com.hj.utils.Json;


@Controller
@RequestMapping("/single")
public class ChangeSingleMission {
	@Autowired
	private SingleResetService singleReSetService;
	@Autowired
	private SingleStopService singleStopService;

	@RequestMapping("/reset")
	public void singleReset(String number,HttpServletRequest req,HttpServletResponse resp){
		resp.setContentType("text/html;charset=UTF-8");
		Json j=new Json();
		j.setMsg(singleReSetService.singleReset(number));
		try {
			PrintWriter pw=resp.getWriter();
			String s=JSON.toJSONString(j);
			pw.write(s);
			pw.flush();
			pw.close();			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	@ResponseBody
	@RequestMapping("/stop")
	public void singleStop(String number,HttpServletRequest req,HttpServletResponse resp){
		resp.setContentType("text/html;charset=UTF-8");
		Json j=new Json();
		j.setMsg(singleStopService.singleStop(number));
		try {
			PrintWriter pw=resp.getWriter();
			String s=JSON.toJSONString(j);
			pw.write(s);
			pw.flush();
			pw.close();			
		} catch (IOException e) {
			e.printStackTrace();
		}		
	}
	
}
